In multithreaded environments where memory is shared, there is the potential for one thread to read data that is being written by another, resulting in incomplete or corrupt data. There is therefore a need to protect shared resources and assure that updates to the resource are atomic with respect to other threads.